#!/bin/sh
# sanitize.sh - Liberate & configure new Slackware system
#
# Written in 2017 by Caleb Herbert <csh@bluehome.net>
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide.  This software is distributed without any
# warranty.
#
# You should have received a copy of the CC0 Public Domain Dedication
# along with this software.  If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.

# Wi-Fi
nmcli dev wifi con "Knoblauch" password "B7D47FFC"

# ----------------------------------------------------------------------
# Sanitize Slackware
# ----------------------------------------------------------------------
# Swap repo
echo 'https://freeslack.net/fxp/freeslack64-14.2/' > /etc/slackpkg/mirror
sed -i 's/#SLACKKEY=".*/SLACKKEY="Connie Dobbs (Free eXpansion Pack for Slackware)"/' /etc/slackpkg/slackpkg.conf
slackpkg update gpg
# Swap kernel
slackpkg install linux-libre-image
grub-mkconfig -o /boot/grub/libreboot_grub.cfg
# Remove junk
# See https://freeslack.net/dokuwiki/doku.php?id=slackware_14.2
x() {
    su -c "slackpkg remove $1"
}
# x google-chrome
# x flashplayer-plugin
x java
x getty-ps
x kernel-firmware
x kernel generic
x kernel-huge
x kernel-modules
x kernel-source
x lha
x unarj
x amp
x seamonkey
x seamonkey-solibs
x bluez-firmware
x ipw2100
x ipw2200
x trn
x zd1211-firmware
x font-bh-ttf
x font-bh-type1
x mozilla-firefox
x mozilla-thunderbird
x xfractint
x xgames
x xv


# ----------------------------------------------------------------------
# Configure
# ----------------------------------------------------------------------
# Fix Emacs
echo > $HOME/.emacs <<EOF
(load-theme 'tango-dark)
(menu-bar-mode 0)
(tool-bar-mode 0)
(scroll-bar-mode 0)
(setq inhibit-startup-message t)
EOF
# sbotools
TAR='sbotools-2.4-noarch-1_SBo.tgz'
URL="https://pink-mist.github.io/sbotools/downloads/$TAR"
curl $URL > $HOME/Downloads/$TAR
su -c "upgradepkg --install-new ~cal/Downloads/$TAR"
# Tor
su -c 'sboinstall tor'
su -c 'sboinstall torsocks'
su -c '/etc/rc.d/rc.tor start'
# Mumble
su -c 'sboinstall mumble'
# Duplicity
su -c 'sboinstall duplicity'
# pass
su -c 'sboinstall password-store'
# IceCat
su -c 'sboinstall icecat'
# ASCIInema
su -c 'sboinstall asciinema'
# Morse code trainer
su -c 'sboinstall aldo'
# avideo
su -c 'sboinstall nose'
su -c 'sboinstall pandoc'
wget 'https://notabug.org/GPast/avideo/raw/archive/2017.8.0/avideo-2017.8.0.tar.gz'
tar -xvf avideo-2017.8.0.tar.gz
cd avideo
su -c 'make install'
# Ekiga
su -c 'sboinstall ekiga'
# Arc theme
su -c 'sboinstall arc-theme'
su -c 'sboinstall arc-icon-theme'
su -c 'sboinstall ambiance-radiance-flat-colors-gtk-theme'
# Noto fonts
su -c 'sboinstall noto-fonts'
# Roboto font
su -c 'sboinstall ttf-roboto'
# Numix Circle
su -c 'sboinstall numix-icon-theme-circle'
# Appearance
su -c 'gtk-update-icon-cache /usr/share/icons/Numix-*'
xfconf-query -c xsettings -p /Net/ThemeName -s "Ambiance-Flat-Aqua"
xfconf-query -c xfwm4 -p /general/theme -s 'Ambiance-Flat-Aqua'
xfconf-query -c xsettings -p /Net/IconThemeName -s "Numix-Circle"
xfconf-query -c xsettings -p /Gtk/FontName -s 'Noto Sans 10'
xfconf-query -c xfwm4 -p /general/title_font -s 'Roboto 10'
xfconf-query -c xfwm4 -p /general/title_alignment -s 'left'
# Japanese input method
su -c 'sboinstall fcitx-mozc'
# Gajim for JMP
su -c 'sboinstall gajim'
# pwgen
su -c 'sboinstall pwgen'
# RetroArch
su -c 'sboinstall RetroArch'
su -c 'sboinstall mupen64plus-libretro'
su -c 'sboinstall mupen64plus'
su -c 'sboinstall m64py'
# Minimal WMs
su -c 'sboinstall mcwm' # floating
su -c 'sboinstall dwm' # tiling
su -c 'sboinstall dmenu' # launcher
su -c 'sboinstall stalonetray' # system tray
su -c 'sboinstall slock' # screen locker
su -c 'sboinstall compton' # effects
su -c 'sboinstall nitrogen' # wallpaper

# Restore data
su -c 'mkdir -p /tmp/restore; duplicity -v8 --gio file:///run/media/cal/8C59-1129/Backups /tmp/restore'
BUP='/tmp/restore/home/cal'
mv $BUP/bin ~cal
restore() {
    mv $BUP/$1 ~cal
}
restore Documents # Skip reddwall in programming/
restore Pictures
restore Templates
restore Videos
restore Abrowser_wallpaper.png
restore .emacs
# restore .emacs.d
restore .gnupg
restore .password-store
restore .ssh
restore .bashrc
restore .bash_aliases
restore .screenrc
restore .local # exclude Trolltech.conf?
restore .config
restore .mozilla
restore .gitconfig
restore .weechat
restore .xchat2

# Wallpaper
WALLPAPER=https://upload.wikimedia.org/wikipedia/commons/3/3e/Beach_parasols_without_people.jpg
curl $WALLPAPER > ~/.wallpaper
xfconf-query --channel xfce4-desktop \
	     --property /backdrop/screen0/monitor0/workspace0/last-image \
	     --set /home/cal/.wallpaper
# Screensaver
su -c 'chown root:root /usr/X11/libexec/xscreensaver/sonar'
su -c 'chmod u+s /usr/X11/libexec/xscreensaver/sonar'

# Panel 1
xfconf-query --channel xfce4-panel \
	     --property /panels/panel-1/position 'p=6;x=0;y=0'
xfconf-query -c xfce4-panel -p /panels/panel-1/background-alpha -s '90'
# Panel 2
xfconf-query --channel xfce4-panel \
	     --property /panels/panel-2/position \
	     --set 'p=3;x=1255;y=407'
# xfconf-query --channel xfce4-panel \
# 	     --property /panels/panel-2/autohide-behavior \
# 	     --set '1'
# # Launchers
# xfconf-query --channel xfce4-panel \
# 	     --property /plugins/plugin-17 \
# 	     --set 'launcher'
# xfconf-query --channel xfce4-panel \
# 	     --property /panels/panel-2/plugin-ids \
# 	     --set
# # Value is an array with 10 items:
# #
# # 7
# # 8
# # 16
# # 9
# # 10
# # 17
# # 11
# # 12
# # 13
# # 14
# xfconf-query --channel xfce4-panel \
# 	     --property /plugins/plugin-17/items \
# 	     --set
# # Value is an array with 1 items:
# #
# # 15024276967.desktop
# xfconf-query --channel xfce4-panel \
# 	     --property /panels/panel-2/plugin-ids \
# 	     --set 
# # Value is an array with 10 items:
# #
# # 7
# # 8
# # 16
# # 9
# # 10
# # 17
# # 11
# # 12
# # 13
# # 14
